package com.mengxiangnongfu.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mengxiangnongfu.constants.Constants;
import com.mengxiangnongfu.domain.SimpleUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.ArrayDeque;
import java.util.List;
import java.util.Properties;
import java.util.Random;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mengxiangnongfu.domain.Menu;
import com.mengxiangnongfu.mapper.MenuMapper;
import com.mengxiangnongfu.service.MenuService;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(rollbackFor = Exception.class)
public class MenuServiceImpl implements MenuService {

    @Resource
    private MenuMapper menuMapper;

    @Override
    public List<Menu> selectMenuTree(boolean isAdmin, SimpleUser simpleUser) {
        QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
        //查询有效条件
        queryWrapper.eq(Menu.COL_STATUS, Constants.STATUS_TRUE);
        //查询菜单类型
        //queryWrapper.eq(Menu.COL_MENU_TYPE, Constants.MENU_TYPE_M);
        //根据父级菜单排序
        queryWrapper.orderByAsc(Menu.COL_PARENT_ID);
        if (isAdmin) {
            return menuMapper.selectList(queryWrapper);
        } else {
            return menuMapper.selectList(queryWrapper);
        }
    }
}
